# -*- coding: utf-8 -*-

# 目前可以使用的接口：查询、预测、上传dicom文件
import json
import requests
from database.TopQuery import top_query
raw_request = {
            "url": 'http://localhost:8042',
            "username": 'orthanc',
            "password": 'orthanc',
            "patient_id": 'b26feadf-13887444-44731978-584920b0-4cc20110',
            # "study_id": '6033181e-9b722416-5991d29e-c1513ac0-e4b21e46',
            "study_id":'1.2.840.113564.345052603883.10332.635963047556560213.29',
            "patient_PN_name": 'PN0002735-DONG_XIU_MEI',
            "inv_pred" : "4",
            "inv_pred_pro" : "0.43499",
            "men_pred" : "1",
            "men_pred_pro" :  "0.999985",
            "patient_name":"WANG_XU",
            "data_path" : r"C:\Users\AMYGDALA\Desktop\data\WANG_XU.zip"
        }
info={
"study_id":"1.2.840.113564.345052603883.10332.635963047556560213.29",
"clinic_info":{"cheif": "主诉", "remark": "备注"}, 
"surgery_info":{"date":"2022-1-10", "region":"前颅底","zhuw":"是","xinp":"一级"},
"pathology_info":{"p_invasive":"是", "p_level":"非一级", "vig":"增值指数", "p_sub":"病理亚型"}
}

# condition={
# "find_state":1, #查询标志位：0为不查询，1为查询
# "name":"BAI_YUE_BIN", #患者姓名
# "check_date":"2019-05-13", #检查日期
# "p_sub":"脑膜皮型", #病理亚型
# "p_invasive":"是", #病理结果是否脑侵袭
# "p_level":"二级" #病理结果是否脑侵袭
# }
condition = {
    "find_state": 1,  # 查询标志位：0为不查询，1为查询
    "name": "",  # 患者姓名
    "check_date1": '',  # 检查日期 小
    "check_date2": '',  # 检查日期 大
    "operation_date1": '',  # 检查日期 小
    "operation_date2": '',  # 检查日期 大
    "p_sub": "哦哦",  # 病理亚型
    "p_invasive": "是",  # 病理结果是否脑侵袭
    "p_level": ""  # 病理结果是否脑侵袭
}

condition2={
"find_state":1,
"name":"DING_ZHI_XIA", 
"check_date":"2017-12-31", 
}

files = {'file': ('72779120',  # 文件名称
              open(r"C:\Users\AMYGDALA\Desktop\data\WANG_XU\72779538", 'rb'),  # 文件路径
              '',  # 文件类型
              )}

# # 发送预测请求 参数包括 patitent_PN_Name 和study_id
# response = requests.get("http://127.0.0.1:80/Predict", json=raw_request)
# print(response)
# result = response.json()
# print(result)
# response = requests.get("http://127.0.0.1:5051/Predict", json=raw_request)
# print(response)
# result = response.json()
# print(result)


# # 发送获取List请求
# response = requests.get("http://127.0.0.1:80/get_list_from_Orthanc", json=raw_request)
# print(response)

# 发送获取dicom请求
# response = requests.get("http://127.0.0.1:80/get_dicom_from_Orthanc", json=raw_request)
# print(response)
# result = response.json()
# print(result)

# 发送mysql数据库更新请求
# response = requests.get("http://127.0.0.1:80/TCL_update", json=raw_request)
# print(response)
# result = response.json() 
# print(result)

# 发送上传dicom文件请求
response = requests.post('http://127.0.0.1:5051/uploadfile', files=files)
print(response)
result = response.json()
print(result)

# 发送上传mri信息请求
# response = requests.get("http://127.0.0.1:80/addmri", json=MRI_info)
# print(response)
# result = response.json()
# print(result)

# 发送查询请求
# response = requests.get("http://127.0.0.1:5051/Query", json=condition)
# print(response)
# result = response.json()
# response = requests.post("http://127.0.0.1:80/login/test1",json=raw_request)
# print(response)
# result = response.json()
# print(result)